import React from 'react';
import { RouteObject } from 'react-router-dom';
import { AuthWrapper } from '../components/AuthRoute';

// 懒加载组件
const Layout = React.lazy(() => import('../components/Layout'));
const Login = React.lazy(() => import('../pages/Login'));
const Home = React.lazy(() => import('../pages/shouYe'));
const NotFound = React.lazy(() => import('../pages/Error/404'));
const Device = React.lazy(() => import('../pages/Device'));
const DeviceDetail = React.lazy(() => import('../pages/Device/Detail'));

// 路由配置
export const routes: RouteObject[] = [
    {
        path: '/',
        element: <AuthWrapper><Layout /></AuthWrapper>,
        children: [
            {
                path: '',
                element: <Home />,
            },
            {
                path: 'home',
                element: <Home />,
            },
            {
                path: 'device',
                element: <Device />,
            },
            {
                path: 'device/:id',
                element: <DeviceDetail />,
            },
            // 动态路由会被添加到这里
        ],
    },
    {
        path: '/login',
        element: <Login />,
    },
    {
        path: '*',
        element: <NotFound />,
    },
];